package com.assets.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.assets.R;

import java.util.List;
import java.util.Map;

public class Scheme_Ap extends BaseAdapter {
    private List<Map<String, Object>> data;
    private LayoutInflater layoutInflater;
    private Context context;
    public Scheme_Ap(Context context, List<Map<String, Object>> data) {
        //传入的data，就是我们要在listview中显示的信息
        this.context = context;
        this.data = data;
        this.layoutInflater = LayoutInflater.from(context);
    }
    public class Info {
        public TextView id_tv;//编码
        public TextView id;
        public TextView date_tv;
        public TextView date;//编码
        public TextView text_tv;
        public TextView text;
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Info info = new Info();
        convertView = layoutInflater.inflate(R.layout.scheme_ap, null);
        info.date = (TextView) convertView.findViewById(R.id.date);
        info.date_tv = (TextView) convertView.findViewById(R.id.date_tv);
        info.id = (TextView) convertView.findViewById(R.id.id);
        info.id_tv = (TextView) convertView.findViewById(R.id.id_tv);
        info.text = (TextView) convertView.findViewById(R.id.text);
        info.text_tv = (TextView) convertView.findViewById(R.id.text_tv);
        info.date.setText((String) data.get(position).get(
                "date"));
        info.date_tv.setText((String) data.get(position).get(
                "date_tv"));
        info.id.setText((String) data.get(position).get(
                "id"));
        info.id_tv.setText((String) data.get(position).get(
                "id_tv"));
        info.text.setText((String) data.get(position).get(
                "text"));
        info.text_tv.setText((String) data.get(position).get(
                "text_tv"));

        return convertView;
    }
}
